import sbt._

import Keys._
import AndroidKeys._

object General {
  val settings = Defaults.defaultSettings ++ Seq (
    name := "couchbase-server",
    version := "0.4.1",
    scalaVersion := "2.9.1",
    crossPaths := false,
    organization := "me.ycy.android",
    libraryDependencies ++= Seq(
      "org.dodgybits" % "shuffle-android" % "1.7.3",
      "org.ektorp" % "org.ektorp" % "1.2.1",
      "org.slf4j" % "slf4j-jdk14" % "1.6.1"
    ),
    platformName in Android := "android-10"
  )


  lazy val fullAndroidSettings =
    General.settings ++
    AndroidProject.androidSettings ++
    TypedResources.settings ++
    AndroidMarketPublish.settings ++ Seq (
      keyalias in Android := "change-me",
      defaultExcludes := "*.so", // avoid dup file when generate apk
      proguardInJars in Android ++= ((file("lib") ** "*.jar") get), // this important
      // NOTE, '#' is not support in proguardOption
      // and must preserve everything, or else will cause segfault
      proguardOption in Android := """
-keep class com.ericsson.otp.** { public protected private *; }
-keep class com.couchbase.** {  public protected private *; }
-keep class me.ycy.android.couchbase.server.replication.* { public protected *; }
-keep class org.slf4j.impl.** { public protected private *; }
-keep class org.ektorp.** { public *; }
-keepattributes *Annotation*
-verbose
-printseeds target/seed.txt
""",
      useProguard in Android := true
    )
}

object AndroidBuild extends Build {
  lazy val main = Project (
    "couchbase-server",
    file("."),
    settings = General.fullAndroidSettings
  )
}
